$(function() {
	//请求参数
	var flowData = {entityName: "OrdersEntity"};
	//
	$.ajax({
		//请求方式
		type : "GET",
		async: false,
		timeout:100,
		//请求的媒体类型
		contentType: "application/json;charset=UTF-8",
		//请求地址
		url : "http://127.0.0.1/",
		//数据，json字符串
		data : {},
		//请求成功
		success : function(result) {
			console.log(result);
			let flowData = JSON.parse('{"states":{"rect1595092098017":{"type":"task","ID":"123","text":{"text":"任务132"},"attr":{"x":453,"y":164,"width":100,"height":50}}},"paths":{}}');
		},
		//请求失败，包含具体的错误信息
		error : function(e){
			console.log("ajax error >>");
			console.log(e.status);
			console.log(e.responseText);

			dd = "";
			// dd += '{"states":{';
			// // dd += ' "rect1595092098017":{"type":"task","ID":"123","text":{"text":"任务132"},"attr":{"x":453,"y":164,"width":100,"height":50}';
			// dd += ' "rect1595148674165":{"type":"state","ID":"","text":{"text":"pending"},"attr":{"x":120,"y":161,"width":100,"height":50}}';
			// dd += ',"rect1595148732314":{"type":"state","ID":"","text":{"text":"payment"},"attr":{"x":282,"y":161,"width":100,"height":50}}';
			// dd += ',"rect1595148735482":{"type":"state","ID":"","text":{"text":"confirm"},"attr":{"x":442,"y":161,"width":100,"height":50}}';
			// dd += ',"rect1595148765012":{"type":"state","ID":"","text":{"text":"purchase"},"attr":{"x":600,"y":161,"width":100,"height":50}}';
			// dd += ',"rect1595148766219":{"type":"state","ID":"","text":{"text":"package"},"attr":{"x":921,"y":160,"width":100,"height":50}}';
			// dd += ',"rect1595148767984":{"type":"state","ID":"","text":{"text":"ship"},"attr":{"x":1080,"y":160,"width":100,"height":50}}';
			// dd += ',"rect1595148861644":{"type":"state","ID":"","text":{"text":"match"},"attr":{"x":760,"y":159,"width":100,"height":50}}';
			// dd += ',"rect1595148944263":{"type":"state","ID":"","text":{"text":"状态"},"attr":{"x":281,"y":320,"width":100,"height":50}}';
			// dd += ',"rect1595148947680":{"type":"state","ID":"","text":{"text":"状态"},"attr":{"x":760,"y":320,"width":100,"height":50}}';
			// dd += '},"paths":{';
			// dd += ' "path1595149558053":{"lineID":"","from":"rect1595148674165","to":"rect1595148732314","dots":[],"text":{"text":"payment", "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"payment"}}}';
			// dd += ',"path1595149607268":{"lineID":"","from":"rect1595148732314","to":"rect1595148735482","dots":[],"text":{"text":"confirm", "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"confirm"}}}';
			// dd += ',"path1595149610411":{"lineID":"","from":"rect1595148735482","to":"rect1595148765012","dots":[],"text":{"text":"purchase","textPos":{"x":0,"y":-10}},"props":{"text":{"value":"purchase"}}}';
			// dd += ',"path1595149613426":{"lineID":"","from":"rect1595148765012","to":"rect1595148861644","dots":[],"text":{"text":"match",   "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"match"}}}';
			// dd += ',"path1595149616602":{"lineID":"","from":"rect1595148861644","to":"rect1595148766219","dots":[],"text":{"text":"packagee","textPos":{"x":0,"y":-10}},"props":{"text":{"value":"packagee"}}}';
			// dd += ',"path1595149620149":{"lineID":"","from":"rect1595148766219","to":"rect1595148767984","dots":[],"text":{"text":"ship",    "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"ship"}}}';

			// dd += ',"path1595150480720":{"lineID":"","from":"rect1595148674165","to":"rect1595148944263","dots":[],"text":{"text":"suspend","textPos":{"x":0,"y":-10}},"props":{"text":{"value":"suspend"}}}';
			// dd += ',"path1595150491726":{"lineID":"","from":"rect1595148732314","to":"rect1595148944263","dots":[],"text":{"text":"suspend","textPos":{"x":0,"y":-10}},"props":{"text":{"value":"suspend"}}}';
			// dd += ',"path1595150493483":{"lineID":"","from":"rect1595148735482","to":"rect1595148944263","dots":[],"text":{"text":"suspend","textPos":{"x":0,"y":-10}},"props":{"text":{"value":"suspend"}}}';
			// dd += ',"path1595151164764":{"lineID":"","from":"rect1595148944263","to":"rect1595148674165","dots":[{"x":218,"y":276}],"text":{"text":"recover","textPos":{"x":0,"y":-10}},"props":{"text":{"value":"recover"}}}';

			// dd += ',"path1595151200427":{"lineID":"","from":"rect1595148765012","to":"rect1595148947680","dots":[],"text":{"text":"suspend","textPos":{"x":0,"y":-10}},"props":{"text":{"value":""}}}';
			// dd += ',"path1595151203813":{"lineID":"","from":"rect1595148861644","to":"rect1595148947680","dots":[],"text":{"text":"suspend","textPos":{"x":0,"y":-10}},"props":{"text":{"value":""}}}';
			// dd += ',"path1595151207385":{"lineID":"","from":"rect1595148766219","to":"rect1595148947680","dots":[],"text":{"text":"suspend","textPos":{"x":0,"y":-10}},"props":{"text":{"value":""}}}';
			// dd += ',"path1595151215108":{"lineID":"","from":"rect1595148947680","to":"rect1595148765012","dots":[{"x":699,"y":275}],"text":{"text":"recover","textPos":{"x":0,"y":-10}},"props":{"text":{"value":""}}}';


			dd += '{"states":{';
			// dd += ' "rect1595092098017":{"type":"task","ID":"123","text":{"text":"任务132"},"attr":{"x":453,"y":164,"width":100,"height":50}';
			dd += ' "rect1595151454031":{"type":"state","ID":"","text":{"text":"start"},   "attr":{"x":120, "y":200,"width":100,"height":50}}';
			dd += ',"rect1595148674165":{"type":"state","ID":"","text":{"text":"pending"}, "attr":{"x":280, "y":200,"width":100,"height":50}}';
			dd += ',"rect1595148732314":{"type":"state","ID":"","text":{"text":"payment"}, "attr":{"x":440, "y":200,"width":100,"height":50}}';
			dd += ',"rect1595148735482":{"type":"state","ID":"","text":{"text":"confirm"}, "attr":{"x":600, "y":200,"width":100,"height":50}}';
			dd += ',"rect1595148765012":{"type":"state","ID":"","text":{"text":"purchase"},"attr":{"x":760, "y":200,"width":100,"height":50}}';
			dd += ',"rect1595148861644":{"type":"state","ID":"","text":{"text":"match"},   "attr":{"x":920, "y":200,"width":100,"height":50}}';
			dd += ',"rect1595148766219":{"type":"state","ID":"","text":{"text":"package"}, "attr":{"x":1080,"y":200,"width":100,"height":50}}';
			dd += ',"rect1595148767984":{"type":"state","ID":"","text":{"text":"ship"},    "attr":{"x":1240,"y":200,"width":100,"height":50}}';

			dd += ',"rect1595152158512":{"type":"state","ID":"","text":{"text":"void"},    "attr":{"x":200, "y":40,"width":100,"height":50}}';
			dd += ',"rect1595152180717":{"type":"state","ID":"","text":{"text":"cancel"},  "attr":{"x":760, "y":40,"width":100,"height":50}}';

			dd += ',"rect1595148944263":{"type":"state","ID":"","text":{"text":"suspend_payment"}, "attr":{"x":430,"y":360,"width":120,"height":50}}';
			dd += ',"rect1595148947680":{"type":"state","ID":"","text":{"text":"suspend_wh"},      "attr":{"x":920,"y":360,"width":100,"height":50}}';

			dd += '},"paths":{';

			dd += ' "path1595149558050":{"lineID":"","from":"rect1595151454031","to":"rect1595148674165","dots":[],"text":{"text":"create",  "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"create"}}}';
			dd += ',"path1595149558053":{"lineID":"","from":"rect1595148674165","to":"rect1595148732314","dots":[],"text":{"text":"payment", "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"payment"}}}';
			dd += ',"path1595149607268":{"lineID":"","from":"rect1595148732314","to":"rect1595148735482","dots":[],"text":{"text":"confirm", "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"confirm"}}}';
			dd += ',"path1595149610411":{"lineID":"","from":"rect1595148735482","to":"rect1595148765012","dots":[],"text":{"text":"purchase","textPos":{"x":0,"y":-10}},"props":{"text":{"value":"purchase"}}}';
			dd += ',"path1595149613426":{"lineID":"","from":"rect1595148765012","to":"rect1595148861644","dots":[],"text":{"text":"match",   "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"match"}}}';
			dd += ',"path1595149616602":{"lineID":"","from":"rect1595148861644","to":"rect1595148766219","dots":[],"text":{"text":"packagee","textPos":{"x":0,"y":-10}},"props":{"text":{"value":"packagee"}}}';
			dd += ',"path1595149620149":{"lineID":"","from":"rect1595148766219","to":"rect1595148767984","dots":[],"text":{"text":"ship",    "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"ship"}}}';

			dd += ',"path1595150480720":{"lineID":"","from":"rect1595148674165","to":"rect1595148944263","dots":[],"text":{"text":"suspend", "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"suspend"}}}';
			dd += ',"path1595150491726":{"lineID":"","from":"rect1595148732314","to":"rect1595148944263","dots":[],"text":{"text":"suspend", "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"suspend"}}}';
			dd += ',"path1595150493483":{"lineID":"","from":"rect1595148735482","to":"rect1595148944263","dots":[],"text":{"text":"suspend", "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"suspend"}}}';
			dd += ',"path1595151164764":{"lineID":"","from":"rect1595148944263","to":"rect1595148674165","dots":[{"x":380,"y":320}],"text":{"text":"recover","textPos":{"x":0,"y":-10}},"props":{"text":{"value":"recover"}}}';

			dd += ',"path1595151200427":{"lineID":"","from":"rect1595148765012","to":"rect1595148947680","dots":[],"text":{"text":"suspend", "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"suspend"}}}';
			dd += ',"path1595151203813":{"lineID":"","from":"rect1595148861644","to":"rect1595148947680","dots":[],"text":{"text":"suspend", "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"suspend"}}}';
			dd += ',"path1595151207385":{"lineID":"","from":"rect1595148766219","to":"rect1595148947680","dots":[],"text":{"text":"suspend", "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"suspend"}}}';
			dd += ',"path1595151215108":{"lineID":"","from":"rect1595148947680","to":"rect1595148765012","dots":[{"x":860,"y":320}],"text":{"text":"recover","textPos":{"x":0,"y":-10}},"props":{"text":{"value":"recover"}}}';

			dd += ',"path1595151215201":{"lineID":"","from":"rect1595151454031","to":"rect1595152158512","dots":[],"text":{"text":"voided",  "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"voided"}}}';
			dd += ',"path1595151215202":{"lineID":"","from":"rect1595148674165","to":"rect1595152158512","dots":[],"text":{"text":"voided",  "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"voided"}}}';

			dd += ',"path1595151215211":{"lineID":"","from":"rect1595148732314","to":"rect1595152180717","dots":[],"text":{"text":"cancel",  "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"cancel"}}}';
			dd += ',"path1595151215212":{"lineID":"","from":"rect1595148735482","to":"rect1595152180717","dots":[],"text":{"text":"cancel",  "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"cancel"}}}';
			dd += ',"path1595151215213":{"lineID":"","from":"rect1595148765012","to":"rect1595152180717","dots":[],"text":{"text":"cancel",  "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"cancel"}}}';
			dd += ',"path1595151215214":{"lineID":"","from":"rect1595148861644","to":"rect1595152180717","dots":[],"text":{"text":"cancel",  "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"cancel"}}}';
			dd += ',"path1595151215215":{"lineID":"","from":"rect1595148766219","to":"rect1595152180717","dots":[],"text":{"text":"cancel",  "textPos":{"x":0,"y":-10}},"props":{"text":{"value":"cancel"}}}';

			dd += '}}';
			console.log(dd);

			flowData = JSON.parse(dd);
		}
	});
	console.log(">>>>>>>>>>>>>>>>>>>>>>>>");
	console.log(flowData);
	console.log("<<<<<<<<<<<<<<<<<<<<<<<<");

	var flowdata=window.localStorage.getItem("data");
	
	$('#myflow').myflow(
		{
			basePath : "",
			allowStateMutiLine:true,
			restore : flowData,
			tools : {
				save : function(data) {
					console.log("保存",eval("("+data+")"));
					//console.log(data);
					window.localStorage.setItem("data",data);
					alert(JSON.stringify(eval("("+data+")")));
					console.log(JSON.stringify(eval("("+data+")")));

				},
				publish:function(data){
					console.log("发布",eval("("+data+")"));
					// alert(data);
				},
				addPath:function(id,data){
					console.log("添加路径",id,eval("("+data+")"));
				},
				addRect:function(id,data){
					//console.log("添加状态",id,eval("("+data+")"));
				},
				clickPath:function(id){
					//console.log("点击线",id)
				},
				clickRect:function(id,data){
					console.log("点击状态",id,eval("("+data+")"));
					// alert(data);
				},
				deletePath:function(id){
					//console.log("删除线",id);
				},
				deleteRect:function(id,data){
					//console.log("删除状态",id,eval("("+data+")"));
				},
				revoke:function(id){

				}
			}
		});

	});